package com.wiscamp.ninechapters.problems.domain.models.problems.problems.simple;

import com.wiscamp.ninechapters.problems.domain.models.problems.problems.SimpleProblem;
import com.wiscamp.ninechapters.problems.domain.models.problems.questions.FactorsMultiplesQuestion;
import com.wiscamp.ninechapters.problems.domain.models.problems.questions.Question;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 简单题-因数倍数
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class FactorsMultiplesProblem extends SimpleProblem {
    /**
     * 单结果计算问题
     */
    private FactorsMultiplesQuestion question;

    @Override
    public Question getCurrentQuestion() {
        return question;
    }

    @Override
    public void setCurrentQuestion(@NotNull Question question) {
        if (!(question instanceof FactorsMultiplesQuestion)) {
            throw new ClassCastException("无效的Question类型转换。");
        }

        this.question = (FactorsMultiplesQuestion) question;
    }

    @Override
    public Collection<Question> getCurrentQuestions() {
        var questions = new ArrayList<Question>();
        questions.add(this.question);
        return questions;
    }
}
